#!/usr/bin/env python
import sys
from os.path import *
import os
import shutil

def get_chartr_dir ():
    ''' Returns the path to the directory to save the maps to '''
    try:
        base = os.environ ['HOME']
    except:
        base = os.environ ['USERPROFILE']
    if os.name != 'nt':
        dirname = os.path.join (base, ".gnome2", "chartr"+os.sep)
    else:
        dirname = os.path.join (base, ".chartr"+os.sep)
    if not os.access (dirname, os.W_OK):
        os.makedirs (dirname)
    return dirname

def get_labyrinth_dir ():
    ''' Returns the path to the directory to save the maps to '''
    try:
        base = os.environ ['HOME']
    except:
        base = os.environ ['USERPROFILE']
    if os.name != 'nt':
        dirname = os.path.join (base, ".gnome2", "labyrinth"+os.sep)
    else:
        dirname = os.path.join (base, ".labyrinth"+os.sep)
    if not os.access (dirname, os.W_OK):
        os.makedirs (dirname)
    return dirname


if __name__ == "__main__":
    chartrdir = get_chartr_dir()
    labyrinthdir = get_labyrinth_dir()
    
    l = os.listdir(labyrinthdir)

    for fl in l:
        shutil.move(labyrinthdir+fl,chartrdir+fl)



